package com.senyint.imsdk;

public class SharedPreferences {
	private PropertiesKit kit = null ;
	
	public SharedPreferences() {
		kit = new PropertiesKit();
	}
	public SharedPreferences(String name) {
		kit = new PropertiesKit(name);
	}

	public SharedPreferences edit() {
		return this;
	}

	public SharedPreferences putString(String key, String val) {
		kit.put(key, val);
		return this;
	}

	public SharedPreferences remove(String key) {
		kit.remove(key);
		return this;
	}
	
	/**
	 * save 
	 */
	public void commit() {
		kit.save();
	}
	
	public SharedPreferences putInt(String key, Integer val) {
		kit.put(key, val);
		return this;
	}
	
	public SharedPreferences putLong(String key, Long val) {
		kit.put(key, val);
		return this;
	}
	
	public String getString(String key, Object object) {
		return kit.getString(key, object==null?null:object.toString());
	}
	
	public Integer getInt(String key, Integer defValue) {
		String val = kit.getString(key);
		if(val == null){
			return defValue ;
		}
		return Integer.parseInt(val);
	}
	
	public Long getLong(String key, Long defValue) {
		String val = kit.getString(key);
		if(val == null){
			return defValue ;
		}
		return Long.parseLong(val);
	}

}
